﻿using PSE.Framework.Communication.Configuration.Adapters;
using PSE.Framework.Communication.Configuration;
using System;
using System.Configuration;
using System.ComponentModel;
using System.Collections.Generic;

namespace PSE.Framework.Communication.Configuration.Adapters
{
    public abstract class AdapterConfiguration : CommunicationConfigurationSection
    {
        [ConfigurationProperty("name", IsRequired = true)]
        public string Name
        {
            get
            {
                return (string)this["name"];
            }
        }

        [ConfigurationProperty("actions", IsRequired = true)]
        public AdapterActionConfigurationCollection Actions
        {
            get
            {
                return (AdapterActionConfigurationCollection)this["actions"];
            }
        }

        private List<string> _actionNames;
        /// <summary>
        /// Propriedade que armazena a lista de nomes das actions configuradas para o adapter
        /// </summary>
        public List<string> ActionNames
        {
            get
            {
                if (_actionNames == null)
                {
                    if (this.Actions != null && this.Actions.Count > 0)
                    {
                        _actionNames = new List<string>();

                        foreach (AdapterActionConfiguration action in Actions)
                        {
                            _actionNames.Add(action.Name);
                        }
                    }
                }
                
                return _actionNames;
            }
        }


    }//end AdapterConfiguration

}